#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qqtverbalexpressions.h>
#include <qqtcore.h>

MainWindow::MainWindow ( QWidget* parent ) :
    QMainWindow ( parent ),
    ui ( new Ui::MainWindow )
{
    ui->setupUi ( this );
    //正则表达式只能做非常简单的事情。
    {
        QQtVerbalExpressions expression = QQtVerbalExpressions()
                                          .searchOneLine()
                                          .startOfLine()
                                          .then ( "http" )
                                          .maybe ( "s" )
                                          .then ( "://" )
                                          .maybe ( "www." )
                                          .anythingBut ( " " )
                                          .endOfLine();

        pline()
                << expression
                << expression.test ( "https://www.google.com" );
    }
    {
        QString replaceMe = "Replace bird with a duck";

        QQtVerbalExpressions expression = QQtVerbalExpressions()
                                          .find ( "bird" );

        pline()
                << expression
                << expression.replace ( replaceMe, "duck" );
    }

}

MainWindow::~MainWindow()
{
    delete ui;
}
